package com.web.dao;

import com.web.entity.CommentReply;
import com.web.entity.CommentReplyList;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CommentReplyMapper {
    @Delete({
        "delete from APP_COMMENT_REPLY",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_COMMENT_REPLY (comment_id, reply_id, ",
        "reply_type, content, ",
        "from_uid, to_uid, ",
        "create_time, modify_time)",
        "values (#{commentId,jdbcType=INTEGER}, #{replyId,jdbcType=VARCHAR}, ",
        "#{replyType,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, ",
        "#{fromUid,jdbcType=VARCHAR}, #{toUid,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(CommentReply record);

    int insertSelective(CommentReply record);

    @Select({
        "select",
        "id, comment_id, reply_id, reply_type, content, from_uid, to_uid, create_time, ",
        "modify_time",
        "from APP_COMMENT_REPLY",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CommentReply selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(CommentReply record);

    @Update({
        "update APP_COMMENT_REPLY",
        "set comment_id = #{commentId,jdbcType=INTEGER},",
          "reply_id = #{replyId,jdbcType=VARCHAR},",
          "reply_type = #{replyType,jdbcType=INTEGER},",
          "content = #{content,jdbcType=VARCHAR},",
          "from_uid = #{fromUid,jdbcType=VARCHAR},",
          "to_uid = #{toUid,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CommentReply record);

    List<CommentReplyList> getReplyList(@Param("commentId") String commentId);
}